﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<SDT.Mobile.Models.ProductDetailsModels>" %>
<%@ Import Namespace="SDT.Lib.Helpers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	<%=Model.Product!=null? Html.Encode(Model.Product.Title):string.Empty %>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="SearchContent" runat="server">
  <% Html.RenderAction("TopSearch", "Product", new { typeid = Model.Product.TypeID, keyword =string.Empty }); %>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div class="tit_bg">
    <span class="tit_name">
        <%var clientName = Model.Product.ProductCategory.Name;
          clientName = Model.Product.City != null && Model.Product.District == null ? clientName + " tại " + Model.Product.City.Name : clientName;
          clientName = Model.Product.District != null ? Model.Product.ProductCategory.Name + " tại " + Model.Product.District.Name + " " + Model.Product.City.Name : clientName;
          clientName = Model.Product.ConvertArea1 != null ? clientName + " diện tích: " + Model.Product.ConvertArea1.Name : clientName;
          clientName = Model.Product.ConvertPrice1 != null ? clientName + " giá: " + Model.Product.ConvertPrice1.Name : clientName;

          var path = "/" + Html.ToUrlFriendly(clientName) + string.Format("/p/{0}/{1}/{2}/{3}/{4}/{5}/{6}",
          Model.Product.TypeID,
          Model.Product.ProductCategory.ID,
          Model.Product.CityID,
          Model.Product.DistrictID,
          Model.Product.ConvertArea,
          Model.Product.ConvertPrice,
          Model.Product.ProjectID.HasValue ? Model.Product.ProjectID.Value:0
          );
          var pathDetail = Model.Product.ProductCategory.Name + " tại " + Model.Product.District.Name + " " + Model.Product.City.Name;
          var dpath = "/" + Html.ToUrlFriendly(pathDetail) + "/" + Html.ToUrlFriendly(Model.Product.Title) + "-p-" + Model.Product.ID + ".html";   %>
        <a href="<%=path %>" ><%= Model.Product.ProductCategory.Name%></a>
    </span>
</div>
<div class="pro-detail">
    <div class="tit_new" style="margin-top:5px">
    <a class="l_red" href="<%=dpath %>"><%=Html.Encode(Model.Product.Title) %></a>
    </div>
    <h3><label>Thông tin mô tả </label></h3>
    <pre style="margin: 0px 5px 0 5px;">
        <%=Model.Product.Summary %>
    </pre>
    <div class="pinfo">
            Giá:
            <span>
                <%=Model.Product.Cost != null && Model.Product.Cost > 0 ? SDT.Lib.Common.Utils.ReadNumber(Model.Product.CurrencyID.HasValue && Model.Product.CurrencyID.Value == 1 ? (double)Model.Product.Cost : (double)Model.Product.TotalCost) + "&nbsp;" + Model.Product.UnitCost : "Thỏa thuận"%></span>
            <span class="pad">&nbsp;</span>
            Diện tích:  <span><%=Model.Product.Area %>m&sup2;</span> <span class="pad">&nbsp;</span>
            Quận/huyện: <span><%=Html.Encode(Model.Product.District.Name)%>,&nbsp;<%=Html.Encode(Model.Product.City.Name)%></span>
    </div>
    <div class="img-map">
        <%var listImg = SDT.Lib.Common.Utils.GenThumbnailInFolder(Model.Product.ID, 500, 375, Model.ImagePath, Model.ImageUrl);
          var listThumImg = SDT.Lib.Common.Utils.GenThumbnailInFolder(Model.Product.ID, 80, 60, Model.ImagePath, Model.ImageUrl); %>
        <%if (listThumImg.Length > 0 && listImg.Length > 0)
          { %>      
        <div class="tit_bg_none">
            <span id="actImg">
               <strong>Xem ảnh tại đây</strong>
            </span>
        </div>
        <div id="photo" class="photo">
            
            <div class="showimg" id="showimg" style="text-align:center; display:block">
                <%if (listImg.Length > 0)
                  { %>
                  <a href="<%=listImg[0] %>">
                    <img src="<%=listImg[0]%>" alt="<%=Html.Encode(Model.Product.Title) %>" />
                  </a>
                <%} %>
            </div>
            <div class="m_footer" id="listimg">                    
              <ul>
                <%for (int i = 0; i < listThumImg.Length; i++)
                  { %>
                  <li style="cursor: pointer;" onclick="showBigImg('<%=listImg[i] %>');">
                    <img width="40" height="30" class="bor_img" alt="<%=Html.Encode(Model.Product.Title) %>" src="<%=listThumImg[i] %>" />			
                  </li>
                <%} %>
              </ul>
            </div>
        </div>
        <%} %>            
        
        <script type="text/javascript">
            function showBigImg($image) {
                $("#showimg a").attr("href", $image);
                $("#showimg img").attr("src", $image);
            };
            $(document).ready(function() {
                $("#photo").hide();
                $("#actImg").click(function() {
                    $("#photo").show();
                });
            });
        </script>
    </div>
    <div class="pro-dt">
        <div class="tit_bg">
            <span class="tit_name">
                Thông tin chi tiết
            </span>
        </div>
        <table class="adminlist" width="100%">
            <tr>
                <td class="it_l">Địa chỉ</td>
                <td><%=Html.Encode(Model.Product.Adress) %></td>
            </tr>
            <%if (Model.Product.Project != null)
              { %>
             <tr>
                <td class="it_l">Thuộc dự án</td>
                <td><%=Html.Encode(Model.Product.Project.Title)%></td>
            </tr>
            <%} %>
             <tr>
                <td class="it_l">Hướng nhà</td>
                <td><%=Html.Encode(Model.Product.Direction!=null? Model.Directions[SDT.Lib.Common.Utils.ParseInt(Model.Product.Direction)]:string.Empty)%></td>
            </tr>
             <tr>
                <td class="it_l">Ngày đăng tin</td>
                <td><%=Model.Product.AddDate.Value.ToString("dd/MM/yyyy") %></td>
            </tr>
             <tr>
                <td class="it_l">Ngày hết hạn</td>
                <td><%=Model.Product.ExpireDate.HasValue? Model.Product.ExpireDate.Value.ToString("dd/MM/yyyy"):string.Empty %></td>
            </tr>
             <tr>
                <td class="it_l">Mã số</td>
                <td><%=Model.Product.ID %></td>
            </tr>
        </table>        
        <div class="clear"></div>        
        <div class="tit_bg">
            <span class="tit_name">
                Thông tin liên hệ
            </span>
        </div>
        <table class="adminlist" width="100%">
            <tr>
                <td class="it_l">Đăng bởi</td>
                <td><%=Html.Encode(Model.Product.ContactName) %></td>
            </tr>
            <tr>
                <td class="it_l">Địa chỉ</td>
                <td><%=Html.Encode(Model.Product.ContactAddress) %></td>
            </tr>
            <tr>
                <td class="it_l">Điện thoại</td>
                <td><%=Html.Encode(Model.Product.ContactMobile) %></td>
            </tr>
            <tr>
                <td class="it_l">Email</td>
                <td><%=Html.Encode(Model.Product.ContactEmail) %></td>
            </tr>
        </table>
    </div>
</div>
<div class="clear">&nbsp;</div>
<% Html.RenderAction("Gets", "Product", new { number = 20, typeid = Model.Product.TypeID, catid = Model.Product.CatID, order = "AddDate", orderDir = "desc", viewName = "Lasted", title = "Tin rao khác" }); %>
<div class="clear">&nbsp;</div> 
<div class="m_footer">
     <div class="f_menu">
         <ul>
             <li>
                <a href="javascript: history.go(-1)" class="l_blue" >Quay lại</a>
             </li>
             <li>
                   <a href="/home" class="l_blue" >Trang chủ</a>
             </li>
             <li>
                   <a href="<%=dpath %>#top" class="l_blue">Lên đầu trang</a>
             </li>
         </ul>
         <div class="clear"></div> 
     </div>
 </div>
 <div class="clear"></div> 
<div class="m_footer">
     <ul>         
         <li style="padding-left:0px">
               <% Html.RenderAction("GetLink", "Link"); %>
         </li>         
     </ul>
 </div>
 <div class="clear"></div> 
</asp:Content>
